(function() {
  'use strict';

  angular.module('starter.pages.tasks.controller', [])
    .controller('TasksCtrl', function($scope, $ionicModal) {
      $scope.items = [{
        name: '任务 Ⅰ',
        badge: 'balanced',
        status: '进行中'
      }, {
        name: '任务 Ⅱ',
        badge: 'balanced',
        status: '进行中'
      }, {
        name: '任务 Ⅲ',
        badge: 'assertive',
        status: '逾期'
      }, {
        name: '任务 Ⅳ',
        badge: 'balanced',
        status: '进行中'
      }];
    })
    .controller('AddTasksCtrl', function($scope) {

      $scope.items = ['任务一', '任务二', '任务三', '任务四'];

      $scope.task = {
        plan: ''
      };

      $scope.groups = [];
      for (var i = 0; i < 10; i++) {
        $scope.groups[i] = {
          name: i,
          items: [],
          show: false
        };
        $scope.groups[i].items.push({
          text: "Backbone",
          value: "bb"
        });
        $scope.groups[i].items.push({
          text: "Angular",
          value: "ng"
        });
        $scope.groups[i].items.push({
          text: "Knockout",
          value: "ko"
        });
      }

      /*
       * if given group is the selected group, deselect it
       * else, select the given group
       */
      $scope.toggleGroup = function(group) {
        group.show = !group.show;
      };
      $scope.isGroupShown = function(group) {
        return group.show;
      };
    });

})();
